<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>工资编辑</title>
  <link rel="stylesheet" href="./static/css/common.css">
  <link rel="stylesheet" href="./static/css/layui.css" media="all">
  <style>
    .my-form-left {
      padding-left: 20px;
    }
  </style>
</head>
<body>
<div class="layui-row">
  <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>编辑工资</legend>
  </fieldset>
  <div class="my-form-left">
    <form class="layui-form layui-form-pane" action="">
      <input type="hidden" name="empId" id="empId">
      <div class="layui-form-item">
        <label class="layui-form-label">职工姓名</label>
        <div class="layui-input-block">
          <input type="text" readonly id="empName" lay-verify="required" autocomplete="off"
                 placeholder="请输入职工姓名"
                 class="layui-input">
        </div>
      </div>
      <div>
        <div class="layui-form-item">
          <label class="layui-form-label">职工部门</label>
          <div class="layui-input-block">
            <input type="text" id="departmentName" autocomplete="off" readonly class="layui-input">
          </div>
        </div>
        <div class="layui-form-item">
          <label class="layui-form-label">职工角色</label>
          <div class="layui-input-block">
            <input type="text" id="roleName" autocomplete="off" readonly class="layui-input">
          </div>
        </div>
        <div class="layui-form-item">
          <label class="layui-form-label">职工工资</label>
          <div class="layui-input-block">
            <input type="text" id="money" name="money" placeholder="请输入员工工资" autocomplete="off" class="layui-input">
          </div>
        </div>
      </div>
      <div class="layui-form-item">
        <button class="layui-btn" lay-submit="" lay-filter="demo2">保存</button>
      </div>
    </form>
  </div>
</div>

<script src="./static/layui.js"></script>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<script>
  layui.use(['carousel', 'form', 'layer', 'jquery'], function () {
    var carousel = layui.carousel
      , form = layui.form
      , layer = layui.layer
      , $ = layui.$;

    //监听提交
    form.on('submit(demo2)', function (data) {
      console.log(data.field);
      $.post("/StaffManagement/salary/save", data.field, data => {
        if (data.code == 200) {
          swal("提示", data.message, "success").then(() => {
            let index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.location.reload();//刷新父页面，注意一定要在关闭当前iframe层之前执行刷新
            parent.layer.close(index); //再执行关闭
          });
        }
      })
      return false;
    });
  });
</script>

</body>
</html>